<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
	<meta name="generator" content="Fog Creek CityDesk 2.0.27" />
<meta name="citydesk" content="AF0A0761/15" />
<title>Bindable LINQ - Reactive Programming</title>
	<style type="text/css">
	body {
		background-color: #fff;
		margin: 0;
		padding: 0;
		font: 10pt segoe UI, arial, tahoma, arial, sans-serif;
	}

	h1 {
		font: bold 18pt "Cambria","Segoe UI",Arial;
		margin: 0px;
	}
	h2 {
		font-size: 12pt;
		font-weight: bold;
	}
	h3 {
		font-size: 11pt;
		font-weight: bold;
	}
	h4, h5 {
		font-size: 10pt;
		font-weight: bold;
	}
	
	#container
	{
		margin: 0px;
		background-color: #fff;
		color: #000;
		border: 1px solid #FFFFFF;
		line-height: 130%;
	}
	
	#top
	{
		padding: 3px;
		padding-left: 10px;
		background-image: url(../../Images/FormHeaderMid-1388x72.png);
		background-repeat: repeat-x;
		padding-bottom: 10px;
		border-bottom: 1px solid #e0e0e0;
	}
	
	#top h1
	{
		padding: 0;
		margin: 0;
	}
	#top h1 a
	{
		color: #000000;
		text-decoration: none;
	}
	
	#top h2
	{
		padding: 0;
		margin: 0;
		margin-top: 5px;
		margin-left: 5px;
	}

	
	#content
	{
		padding: 15px;
		padding-top: 0px;
	}
	
	#footer
	{
		clear: both;
		margin: 0;
		padding: .5em;
		color: #333;
		background-color: #D4DFFF;
		border-top: 1px solid #FFFFFF;
	}
	
	#content a 
	{
		color:#105CB6;
		font-weight: bold;
		text-decoration:none;
	}
	
	#content a:hover
	{
		text-decoration:underline;
	}
	
	#content p { line-height: 150%; }

	#content li { margin: 5px; }
	#content img { margin: 10px; }

	#nextPrevBar 
	{
		border-top: 1px solid #e0e0e0;
		padding: 15px;
	}
		
	#nextPrevBar a 
	{
		color:#105CB6;
		font-weight: bold;
		text-decoration:none;
	}
	
	#nextPrevBar a:hover
	{
		text-decoration:underline;
	}

	pre
	{
		background:#F9F9F9 none repeat scroll 0 50%;
		border-color:#E0E0E0;
		border-style:solid;
		border-width:1px 1px 1px 7px;
		color:#222277;
		font-family:Consolas,Lucida Console,Courier New,serif;
		font-size:10pt;
		line-height:110%;
		overflow:auto;
		padding:7px;
	}

	</style>
</head>
<body>

	<div id="container">
		<div id="top">
			<a href="../../Index.html"><img height="100" alt="" src="../../Images/Logo.png" width="475" border="0" /></a>
			<h2>Reactive Programming</h2>
		</div>
	
		<div id="content">
			

<p><strong><em>Reactive Programming</em></strong> is programming paradigm with a focus on automatic reactions to changes in data. While other programming paradigms, such as object oriented or functional programming, focus on <em>discreet evaluation</em> of code, the reactive programming paradigm instead focuses on <em>continuous evaluation,</em> and <em>propagation of change</em>.</p>
<p>To understand the difference between discreet and continuous evaluation, consider the following familiar C# code:</p>

<pre>
decimal total = 0;
IList&lt;LineItem&gt; lineItems = ...;
foreach (var item in lineItems) 
{
    total += item.Quantity * item.Price;
}
</pre>

<p>The value of the <strong>total</strong> is <em>derived</em> from the <strong>lineItems</strong> collection. But in this case, once the <em>foreach</em> loop has completed and the total variable assigned, this relationship is lost. If the lineItems collection, from which the total was derived from, changes, the total will not change. You can think think of this code as representing a "point-in-time" snapshot of the total.</p>

<p>In a reactive programming language, the relationship between the source - lineItems - and the destination - total - should be maintained at all times, and changes to the source should be propagated.</p>

<p>Bindable LINQ allows you to use the familiar syntax of LINQ queries in a reactive programming way. For example, the order totaling code above could be written in Bindable LINQ as:</p>

<pre>
ObservableCollection&lt;LineItem&gt; lineItems = ...;
IBindable&lt;decimal&gt; total = lineItems.AsBindable().Sum(li =&gt; li.Quantity * li.Price);
</pre>

<p>Further reading:</p>
<ul>
<li><a href="http://en.wikipedia.org/wiki/Reactive_programming" target="_blank">Reactive Programming</a> on Wikipedia</li>
<li><a href="http://en.wikipedia.org/wiki/Functional_reactive_programming" target="_blank">Functional Reactive Programming</a> on Wikipedia</li>
</ul>
					
		</div>
	
		<div id="nextPrevBar">
		
			<div style='float: left; width: 300px;'>
				
				    <a href="Overview.html">Previous: Bindable LINQ Background</a>
				
			</div>
			<div style='float: right; width: 300px; text-align: right;'>
				
				    <a href="LINQ.html">Next: LINQ</a>
				
			</div>
		
		<div style='text-style: italic; text-align: center; clear: both; margin-top: 10px;'>
			Copyright &copy; Paul Stovell, 2007. All rights reserved. <br/>
			Bindable LINQ code is <a href="../../License.html">licensed</a> under the New BSD open source license.
		</div>
	</div>
</body>
</html>
